App = require "utils.moai.app"

App.init("foo")

chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 _+-()[]{}|\/?.,<>!~`@#$%^&*\'":;'
fontScale = 2

w, h = 1, 1
textbox = MOAITextBox.new ()
textbox:setColor(1, 1, 1)
textbox:setAlignment(MOAITextBox.CENTER_JUSTIFY)
textbox:setYFlip(true)
textbox:setRect(-w/2, -h/2, w/2, h/2)
textbox:setLoc(0.5, 0.5)

textbox.font = MOAIFont.new()
textbox.font:load('arialbd.ttf')
textbox.font:preloadGlyphs( chars, math.ceil( 4 * fontScale ), 72 )
textbox:setFont( textbox.font )


function pointer_moved(x, y)
    textbox:setString(string.format("x=%s, y=%s", x, y))
end

if MOAIInputMgr.device.pointer then
    MOAIInputMgr.device.pointer:setCallback(pointer_moved)
end

App.layer.default:insertProp(textbox)
